<template>
<el-row>
    <el-row>
    <!--新增/编辑界面 AqComment 问题评论表-->
        <el-form :model="editForm"  label-width="120px" :rules="editFormRules" ref="editFormRef">
            <el-form-item label="编号" prop="id">
                <el-input show-style="origin" v-model="editForm.id" placeholder="主键" :maxlength="50" @change="editSomeFields(editForm,'id',$event)" :disabled="disabledJudge('id')"/>
            </el-form-item> 
            <el-form-item label="评论人" prop="userid" v-if="false">
                <el-input show-style="origin" v-model="editForm.userid" placeholder="评论人" :maxlength="50" @change="editSomeFields(editForm,'userid',$event)" :disabled="disabledJudge('userid')"/>
            </el-form-item>  
            <el-form-item label="评论人" prop="username">
                <el-input show-style="origin" v-model="editForm.username" placeholder="评论人姓名" :maxlength="50" @change="editSomeFields(editForm,'username',$event)" :disabled="disabledJudge('username')"/>
            </el-form-item>
            <el-form-item label="时间" prop="createDate">
                <el-date-picker type="date" placeholder="选择日期" show-style="origin" v-model="editForm.createDate"  value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd" :disabled="disabledJudge('createDate')"></el-date-picker>
            </el-form-item>
            <el-form-item label="评论内容" prop="context">
                <editor v-if="visible" :branch-id="userInfo.branchId" :key="'context'" ref="context" v-model="editForm.context"  @change="editSomeFields(editForm,'context',$event)" :disabled="disabledJudge('context')"> </editor>  
             </el-form-item>
             <el-form-item label="状态" prop="isShow">
                <mdp-select item-code="faqStatus" v-model="editForm.isShow" :maxlength="1" @change="editSomeFields(editForm,'isShow',$event)" :disabled="disabledJudge('isShow')"/>
            </el-form-item>
            <el-form-item label="星级" prop="star">
                <el-input show-style="origin" v-model="editForm.star" placeholder="星级" :maxlength="1" @change="editSomeFields(editForm,'star',$event)" :disabled="disabledJudge('star')"/>
            </el-form-item>
            <el-form-item label="问题编号" prop="questionId">
                <el-input show-style="origin" v-model="editForm.questionId" placeholder="问题编号" :maxlength="50" @change="editSomeFields(editForm,'questionId',$event)" :disabled="disabledJudge('questionId')"/>
            </el-form-item>
            <el-form-item label="上级评论" prop="pcommentId">
                <el-input show-style="origin" v-model="editForm.pcommentId" placeholder="上级评论" :maxlength="50" @change="editSomeFields(editForm,'pcommentId',$event)" :disabled="disabledJudge('pcommentId')"/>
            </el-form-item>
            <el-form-item label="点赞数量" prop="praiseSum">
                <el-input show-style="origin" v-model="editForm.praiseSum" placeholder="点赞数量" :maxlength="10" :disabled="disabledJudge('praiseSum')"/>
            </el-form-item>
            <el-form-item label="接收本条评论的用户编号" prop="toUserid">
                <el-input show-style="origin" v-model="editForm.toUserid" placeholder="接收本条评论的用户编号" :maxlength="50" @change="editSomeFields(editForm,'toUserid',$event)" :disabled="disabledJudge('toUserid')"/>
            </el-form-item>
            <el-form-item label="接收本条评论的用户名称" prop="toUsername">
                <el-input show-style="origin" v-model="editForm.toUsername" placeholder="接收本条评论的用户名称" :maxlength="50" @change="editSomeFields(editForm,'toUsername',$event)" :disabled="disabledJudge('toUsername')"/>
            </el-form-item>
            <el-form-item label="层级" prop="lvl">
                <el-input show-style="origin" v-model="editForm.lvl" placeholder="层级0,1,2,3,4" :maxlength="1" @change="editSomeFields(editForm,'lvl',$event)" :disabled="disabledJudge('lvl')"/>
            </el-form-item>
            <el-form-item label="部门" prop="deptid">
                <el-input show-style="origin" v-model="editForm.deptid" placeholder="部门" :maxlength="50" @change="editSomeFields(editForm,'deptid',$event)" :disabled="disabledJudge('deptid')"/>
            </el-form-item>
            <el-form-item label="机构编号" prop="branchId">
                <el-input show-style="origin" v-model="editForm.branchId" placeholder="机构编号" :maxlength="50" @change="editSomeFields(editForm,'branchId',$event)" :disabled="disabledJudge('branchId')"/>
            </el-form-item>
        </el-form>
    </el-row>
    <slot name="footer" :page="this">
        <el-row v-if="showBtn!==false" style="float:right;" class="footer">
            <el-button @click.native="close">关闭</el-button>
            <el-button v-if="currOpType=='add'" v-loading="load.edit" type="primary" @click.native="saveSubmit" :disabled="disabledJudge('addBtn') || !checkBtnQx('addBtn',menuDefId) || load.edit">提交</el-button>
        </el-row>
    </slot>
</el-row>
</template>

<script>
import * as AqCommentApi from '@/api/mdp/arc/aq/aqComment';
import { mapGetters } from 'vuex'
import { MdpFormMixin } from '@/components/mdp-ui/mixin/MdpFormMixin.js';
import Editor from '@/components/Tinymce';  

export default {
    name:'aqCommentForm',
    mixins:[MdpFormMixin],
    components: {
        Editor
    },
    computed: {
    },
    props:{
    },
    watch: {
    },
    data() {
        return {
            menuDefId:'',//menu_def.id 菜单表菜单编号，用于按钮权限判断
            pkNames:["id"],//表格主键的java属性名称，驼峰命名，默认为id,支持多主键
            currOpType:'add',//表单 add、edit，所有按钮可动、detail-只看不能操作
            editFormRules: {
                id:[
                //{ required: true, message: '此项必填', trigger: 'change' },
                //{ min: 1,max: 200, message: '长度在1到200之间', trigger: 'change'}
                ]
            },
            editForm: {
                id:'',userid:'',username:'',star:'',createDate:'',questionId:'',pcommentId:'',praiseSum:'',isShow:'',toUserid:'',toUsername:'',lvl:'',deptid:'',context:'',branchId:''
            },
            //增删改查(含批量)接口
            apis:{
                queryById: AqCommentApi.queryAqCommentById,
                add: AqCommentApi.addAqComment,
                edit: AqCommentApi.editAqComment,
                editSomeFields: AqCommentApi.editSomeFieldsAqComment
            }
        }
    },
    methods: {
         //由组件扩展添加其它的初始页面的逻辑(mounted+onOpen都会调用此函数，建议只添加公共逻辑)
         initCurrData(){

         },
        /**
         * 检查参数是否满足调用后台接口的条件
         * @returns true / false
         */
        preParamCheck(params){
            return true;
        },

        /**
          * 设置某个关键词、按钮、输入框禁用 disabledRules['addBtn']=false
          * 判断某个对象是否可编辑 this.disabledJudge('addBtn')==false
          */
        disabledRulesInit(disabledRules){

        },
        /**
         * 对修改的字段进行判断，返回false ,将取消更新数据库,由组件扩展
         * @param {*} row 当前选中的行
         * @param {*} fieldName 修改的字段名
         * @param {*} $event 修改后的值
         * @param {*} params 将要提交服务器的参数
         * @returns true/false 返回false ,将取消更新数据库
         */
        editSomeFieldsCheck(row,fieldName,$event,params){
            params[fieldName]=$event
            return true;
        },
    },
    mounted() {

    }
}

</script>

<style scoped>

</style>